<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.biz.utils.ConfigUtil" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
    String resoursUrl = ConfigUtil.get("RESOURCES_URL");
%>
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>个人资料</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="format-detection" content="telephone=no" />
  <jsp:include page="/jsp/inc_head.jsp"></jsp:include>
<style>
    #zhezhao{
    background:#333;
    bottom: 0;
	width:100%;
    display: none;
    left: 0;
    opacity: 0.9;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1000;
	}
    .zzcltext{
		font-size:18px;
		color:#fff;
		margin-top: 200px;
		text-align:center;
		font-family: "Segoe UI","Lucida Grande",Helvetica,Arial,"Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif;
	}
</style>
</head>

<body style="padding-bottom:50px;">
<div class="am-g">
	<div class="am-u-sm-12 am-pad-none grzl_sex">
    	<div class="am-u-sm-6 am-text-right" style="padding-right:30px;">
        	<label  for="sex_nan" class="sex_label sexnan">
            	<img onclick="setSexman(1);" src="<%=resoursUrl%>resources/assets/image/sex_nan.png" width="28"/>男
            </label>
        </div>
        <div class="am-u-sm-6 am-text-left" style="padding-right:30px;">
        	<label for="sex_nv" class="sex_label sexnv">
            	<img onclick="setSexman(0);" src="<%=resoursUrl%>resources/assets/image/sex_nv1.png" width="28"/>女
            </label>
        </div>
    </div>
    <div class="am-u-sm-12 am-pad-none">
    	<div class="am-u-sm-12 am-pad-none grzl_lie">
        	<div class="am-u-sm-3">
            	姓名
            </div>
            <div class="am-u-sm-9 am-text-right">
            	<input id="name" type="text" value="" placeholder="请填写您的姓名"/>
            </div>
        </div>
    	<div class="am-u-sm-12 am-pad-none grzl_lie">
        	<div class="am-u-sm-3">
            	邮箱
            </div>
            <div class="am-u-sm-9 am-text-right">
            	<input id="email" type="text" value="" placeholder="请填写您的邮箱"/>
            </div>
        </div>
    </div>
</div>
<div onclick="save();" class="am-g btm_fixed">
	<div class="am-u-sm-12 am-text-center">
    	保存
    </div>
</div>
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
	<div class="am-modal-dialog">
		<div class="am-modal-hd" id="alert_title">哎呦喂，出错啦</div>
		<div class="am-modal-bd" id="alert_message"></div>
		<div class="am-modal-footer">
			  <span class="am-modal-btn">确定</span>
		</div>
	</div>
</div>
<div id="zhezhao">
	<div class="zzcltext">
	         正在处理，请稍等。。。。
	</div>
</div>
<input type="hidden" id="sex" value="1" />
<script>
 var ajaxpath="${pageContext.request.contextPath}";

$(function(){
	if($(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan1.png"))
	{
		$(".sexnan").click(function(){
			$(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan.png");
			$(".sexnv").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nv1.png");
		});
		$(".sexnv").click(function(){
			$(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan1.png");
			$(".sexnv").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nv.png");
		});	
	}
	if($(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan.png"))
	{
		$(".sexnan").click(function(){
			$(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan.png");
			$(".sexnv").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nv1.png");
		});
		$(".sexnv").click(function(){
			$(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan1.png");
			$(".sexnv").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nv.png");
		});	
	}
	loudMyInfo();
});

//加载个人资料
function loudMyInfo(){
    var url=ajaxpath+"/userCenter/queryMyInfo.do?";
	$.get(url, function(data){
	     if(data.personName!=null&&data.personName!=""){
	         $("#name").val(data.personName);
	     }
	     if(data.email!=null&&data.email!=""){
	         $("#email").val(data.email);
	     }
	     if(data.sex==0){
	         $(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan1.png");
			 $(".sexnv").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nv.png");
	     }else{
	         $(".sexnan").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nan.png");
			 $(".sexnv").find("img").attr("src","<%=resoursUrl%>resources/assets/image/sex_nv1.png");
	     }     
	});
}

function setSexman(value){
    $("#sex").val(value);
}

function save(){
    var sex=$("#sex").val();
    var name=$("#name").val();
    var email=$("#email").val();
    if (!name) {
		$("#alert_message").html("姓名不可为空");
		$("#my-alert").modal('open');  					
		return;
	}
	$("#zhezhao").css("display","block");//遮罩层
	var url=ajaxpath+"/userCenter/saveMyInfo.do?sex=" + sex + "&name="+ encodeURI(encodeURI(name)) + "&email="+ email;
	$.get(url, function(data){
	     if (data.result == "success") {
				$("#alert_title").html("提示");
				$("#alert_message").html("保存成功！");
				$("#my-alert").modal('open');
				window.location.href = ajaxpath+"/client_toClientCenter.do?guid="+ new Date(); 
		  } else {
				$("#alert_message").html("保存失败!");
				$("#my-alert").modal('open');
				$("#zhezhao").css("display","none");//遮罩层
		  }
	});
}
</script>
</body>
</html>
